package com.zxx.pattern.chainPattern.chain2;

/**
 * @author zxx on 2021/1/26
 */
public class ChainPatternDemo {

    private static AbstractLogger getChainLogger(){
        AbstractLogger errorL = new ErrorLogger(AbstractLogger.ERROR);
        AbstractLogger fileL = new FileLogger(AbstractLogger.DEBUG);
        AbstractLogger consoleL = new ConsoleLogger(AbstractLogger.INFO);

        errorL.setNextLogger(fileL);
        fileL.setNextLogger(consoleL);

        return errorL;
    }

    public static void main(String[] args) {
        AbstractLogger logger = getChainLogger();
        System.out.println("Level:" + logger.level);
        System.out.println("nextLogger:" + logger.nextLogger);
        logger.logMessage(AbstractLogger.ERROR,"This is an info");
        System.out.println("nextLogger:" + logger.nextLogger);

        //logger.logMessage(AbstractLogger.DEBUG, "This is a debug");
    }

}
